<template>
  <el-dialog title="菜单权限编辑" width="500px" v-model="dialogFormVisible">
    <el-form :model="form" size="small">
      <el-form-item label="名称" :label-width="formLabelWidth">
        <el-input v-model="form.permission_name" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="所属父集" :label-width="formLabelWidth">
        <el-select v-model="form.parent_id" placeholder="请选商户">
          <el-option label="华为科技" :value="1"></el-option>
          <el-option label="腾讯科技" :value="2"></el-option>
          <el-option label="小米科技" :value="3"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="类型" :label-width="formLabelWidth">
        <el-select v-model="form.permission_type" placeholder="请选择">
          <el-option label="页面" :value="1"></el-option>
          <el-option label="按钮" :value="2"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="路由地址" :label-width="formLabelWidth">
        <el-input v-model="form.permission_url" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="路径参数" :label-width="formLabelWidth">
        <el-input
          v-model="form.permission_parameter"
          autocomplete="off"
        ></el-input>
      </el-form-item>
      <el-form-item label="权限KEY" :label-width="formLabelWidth">
        <el-input v-model="form.permission_key" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="排序" :label-width="formLabelWidth">
        <el-input v-model="form.permission_sort" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="图标" :label-width="formLabelWidth">
        <el-popover placement="top" :width="460" trigger="click">
          <template #reference>
            <el-button icon="el-icon-caret-bottom" size="mini"></el-button>
          </template>
          <ul class="icon-list-ul">
            <li v-for="(item, index) in 20" :key="index">
              <i class="el-icon-edit"></i>
            </li>
          </ul>
        </el-popover>
      </el-form-item>
      <el-form-item label="描述" :label-width="formLabelWidth">
        <el-input
          type="textarea"
          v-model="form.permission_describe"
          autocomplete="off"
        ></el-input>
      </el-form-item>
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button size="small" @click="cancelFunc()">取 消</el-button>
        <el-button size="small" type="primary" @click="confirmFunc()"
          >确 定</el-button
        >
      </span>
    </template>
  </el-dialog>
</template>
        //菜单图标
        permission_icon: "",
<script>
export default {
  data() {
    return {
      //是否显示
      dialogFormVisible: false,
      //表单数据
      form: {
        //名称
        permission_name: "",
        //父集ID
        parent_id: 0,
        //权限类别
        permission_type: 1,
        //路由地址
        permission_url: "",
        //路径参数
        permission_parameter: "",
        //权限唯一标识
        permission_key: "",
        //菜单图标
        permission_icon: "",
        //排序
        permission_sort: 100,
        //描述
        permission_describe: "",
      },
      //左边标签宽度
      formLabelWidth: "120px",
    };
  },
  props: {
    visible: Boolean,
  },
  watch: {
    //监听是否显示
    visible(newVal, oldVal) {
      if (newVal != oldVal) {
        this.dialogFormVisible = newVal;
      }
    },
  },
  created() {},
  methods: {
    /**
     * 确认
     */
    confirmFunc() {
      this.$message({
        type: "success",
        message: "操作成功!",
      });
      this.cancelFunc();
    },

    /**
     * 取消
     */
    cancelFunc() {
      this.$emit("close", false);
    },
  },
};
</script>

<style lang="scss">
.icon-list-ul {
  display: flex;
  flex-wrap: wrap;
  li {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 4px;
    width: 40px;
    height: 40px;
    border: 1px solid #bae8ff;
    cursor: pointer;
  }
  :hover{
      background: #bae8ff;
  }
}

</style>